package com.zuokun.controller;

import com.zuokun.annotation.Controller;
import com.zuokun.annotation.ProtocolMapping;
import com.zuokun.protol.MsgBase;
import com.zuokun.protol.room.*;
import com.zuokun.service.RoomService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Controller
@Slf4j
public class RoomController {

    @Autowired
    private RoomService roomService;

    /**
     * 查询房间列表
     *
     * @param msgGetRoomList
     * @return
     */
    @ProtocolMapping("MsgGetRoomList")
    public MsgGetRoomList getRoomList(MsgGetRoomList msgGetRoomList) {
        return roomService.getRoomList(msgGetRoomList);
    }

    /**
     * 创建房间
     *
     * @param msgCreateRoom
     * @return
     */
    @ProtocolMapping("MsgCreateRoom")
    public MsgCreateRoom createRoom(MsgCreateRoom msgCreateRoom) {
        return roomService.createRoom(msgCreateRoom);
    }

    /**
     * 进入房间
     *
     * @param msgEnterRoom
     * @return
     */
    @ProtocolMapping("MsgEnterRoom")
    public MsgBase enterRoom(MsgEnterRoom msgEnterRoom) {
        return roomService.enterRoom(msgEnterRoom);
    }

    /**
     * 离开房间
     *
     * @param msgLeaveRoom
     * @return
     */
    @ProtocolMapping("MsgLeaveRoom")
    public MsgLeaveRoom leaveRoom(MsgLeaveRoom msgLeaveRoom) {
        return roomService.leaveRoom(msgLeaveRoom);
    }

    /**
     * 获取房间信息
     *
     * @param msgGetRoomInfo
     * @return
     */
    @ProtocolMapping("MsgGetRoomInfo")
    public MsgBase getRoomInfo(MsgGetRoomInfo msgGetRoomInfo) {
        return roomService.getRoomInfo(msgGetRoomInfo);
    }
}
